#include <stdio.h>

int judge_leep_year (int y)
{

    if (y % 400 == 0 || y % 4 == 0 && y % 100 != 0) // 设立判断,当该年能被400整除时,又或者满足能被四整除且不能被100整除的时候,运行函数
    {

        return 1 ;

    }

    return 0 ;

}

void judge_month (int flag , int m)
{

    if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12)
    {

        printf("31") ;

    }

    else if (m == 2)
    {

        if (flag)
        {

            printf("29") ;

        }

        else
        {

            printf("28") ;

        }

    }

    else
    {

        printf("30") ;

    }

}

int main ()
{

    int y , m ;

    scanf("%d %d" , &y , &m) ;

    int flag = judge_leep_year (y) ;

    judge_month (flag , m) ;

    return 0 ;
}